package com.back.exception;

import com.back.Dao.R;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class GlobalExecption {
    @ExceptionHandler(ServiceException.class)
    @ResponseBody//转换为json
    public R serviceException(ServiceException e){
        return R.error(e.getCode(),e.getMessage());
    }
}
